<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>任务管理</title>
	<script type="text/javascript">
	$(function() {
		$("#queryForm").validate();
  });
	var datatable_content;
		$(function(){
			initTable();
		});
		
		function initTable(){
			datatable_content = $("#contentTable").dataTable({
			   "bServerSide":true,
	           "sAjaxSource":'${ctx}/performanceFee/page',
	           "fnServerData": callback,
	           "bFilter": false,
	           "bSort": false,
	           "sZeroRecords": "查询无记录！",
	           "bProcessing": true,
	           "oLanguage": {
	               "sUrl": '${ctx}/static/v2/js/plugins/datatables/cn.txt'
	            },
	             "aoColumns":[
	             	 {"mData": "warehouseCode"},
	             	 {"mData": "optype"},
	             	 {"mData": "customerCode"},
	             	 {"mData": "fee"},
	             	 {"mData": "id"},
	             ],
	             "aoColumnDefs":[
	             	{"aTargets": [1],
		              "mRender": function (data, display, row) {
		            	  var opt = "";
		            	  if(data=="1")
	            		  {
		            		  opt="卸货";
	            		  }else if(data=="2")
	            		  {
		            		  opt="上架";
	            		  }else if(data=="3")
	            		  {
		            		  opt="打单";
	            		  }else if(data=="4")
	            		  {
		            		  opt="配单";
	            		  }else if(data=="5")
	            		  {
		            		  opt="拣货";
	            		  }else if(data=="6")
	            		  {
		            		  opt="包装";
	            		  }else if(data=="7")
	            		  {
		            		  opt="发货";
	            		  }
			        	 return opt;
			           }
		            },
	             	{"aTargets": [4],
		              "mRender": function (data, display, row) {
			        	return "<a class=\"btn btn-danger\" href=\"${ctx}/performanceFee/delete/"+data+"\">删除</a>"; 
			           }
		            },
	             ],
			});
		}
		
		function callback( sSource, aoData, fnCallback ) {
		 aoData.push( { "name": "search_EQ_warehouseCode", "value": $("#search_EQ_warehouseCode").val()});
			 //查询参数
		   $.ajax({ 
		       "type": "post",
		       "contentType": "application/json", 
		       "url": sSource,    
		       "dataType": "json",   
		       "data": JSON.stringify(aoData),
		       "success": fnCallback  
		   });    
		}
		
		function query(){
			datatable_content.fnDestroy();
			initTable();
		}
		
</script>
</head>

<body>
<section class="content">
		<c:if test="${not empty message}">
			<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
		</c:if>
		<div class="row">
			<div class="col-md-12">
			<div class="box box-solid box-primary">
			<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	
			<form class="form-search" id="queryForm" action="#">
				<div class="col-sm-3">
					<div class="input-group col-sm-12">
						<span class="input-group-text">作业仓库: </span> 
						<select class="form-control"  name="search_EQ_warehouseCode" id="search_EQ_warehouseCode" class="input-medium required">
							<option value=""></option>
							<c:forEach items="${warehouseList}" var="w">
							   <option value="${w.groupCode}" 
							   <c:if test="${warehouseCode eq w.groupCode }">selected=selected</c:if>
							   >${w.groupName}</option>
						   </c:forEach>
						 </select> 
					</div>
				</div>
				
			    <button type="button" onclick="query()" class="btn btn-info">搜索</button>
			    <a class="btn btn-info" href="${ctx}/performanceFee/v2_create">登记</a>
		    </form>
	    </div>
	</div>
	</div>
	</div>
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-primary">
				<div class="box-header"></div>
				<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
			<th>仓库</th>
			<th>工序</th>
			<th>客户</th>
			<th>单位费用</th>
			<th>管理</th>
		</tr></thead>
		<tbody>
		</tbody>
	</table>
	</div>
	</div>
	</div>
</div>
</section>	
</body>
</html>
